#include "junix.h"

int main(int argc, char **argv)
{
	char buf[LINE_MAX];
	int cnnfd,fd;
	ssize_t sz;
    fd_set rdset;
    FD_ZERO(&rdset);
    

	setlocale(LC_ALL,"POSIX");

	fd=passive_sock("80","tcp",5);
	while(1)
	{
		cnnfd=Accept(fd,NULL,NULL);
        FD_SET(cnnfd,&rdset);


		while( (sz=Read(cnnfd,buf,LINE_MAX))>0)
		{
			Write(STDOUT_FILENO,buf,sz);
			Write(cnnfd,buf,sz);
		}
		Close(cnnfd);
	}
    exit(0);
}

